package cn.chrisx.drad.platform;

import android.app.Activity;

import cn.chrisx.drad.core.DrAdConfig;
import cn.chrisx.drad.core.DrAdError;
import cn.chrisx.drad.wrap.Ad;
import cn.chrisx.drad.wrap.AdListener;

/**
 * @author Jzfox <jz_boy@163.com>
 * @version 1.0
 * @date 2018/9/25 11:54
 * @description
 * @copyright ©2018 www.jzfox.net All rights reserved.
 */
public abstract class BasePlatformAd implements Ad {


    private AdListener adListener;

    protected DrAdConfig drAdConfig;

    @Override
    public void setAdListener(AdListener adListener) {
        this.adListener = adListener;
    }


    @Override
    public void onResume(Activity activity) {

    }

    @Override
    public void setAdConfig(DrAdConfig config) {
        this.drAdConfig = config;
    }

    @Override
    public void onPause(Activity activity) {

    }

    protected void onAdLoadSuccess() {
        if (adListener != null) adListener.onAdLoadSuccess(this);
    }

    protected void onAdLoadFailed(int code, DrAdError status) {
        if (adListener != null) adListener.onAdLoadFailed(this, code, status);

    }

    protected void onAdShow() {
        if (adListener != null) adListener.onAdShow(this);
    }

    protected void onAdDismiss() {
        if (adListener != null) adListener.onAdDismiss(this);
    }

    protected void onAdClicked() {
        if (adListener != null) adListener.onAdClicked(this);
    }

    protected void onReward(boolean suc, Object reward) {
        if (adListener != null) adListener.onReward(this, suc, reward);
    }
}
